<?
if(!ANTIHACK) die("ANTIHACK...");
global $baselink;
if($_GET["code"]!="")
{
	$code=$_GET["code"];
	$q=query("select * from page,menu where page.menuid=menu.id and code='$code'");
	$r=fetch($q);
	$r['content']=str_replace("&#39;","'",$r['content']);
	preg_match_all("/(.*?){_block code='([a-zA-Z0-9\-]*)'}/si",$r['content'],$block);
	$content=$block[1];
	$block=$block[2];
	if(count($block)>0){
	$pos="{_block code='".$block[count($block)-1]."'}";
	$content[]=substr($r['content'],strpos($r['content'],$pos)+strlen($pos));
	$r['content']=$content;
	$r['block']=$block;
	}
	
	
}
else if($_GET["id"]!="")
{
	$id=$_GET["id"];
	$q=query("select * from post where id=$id");
	$r=fetch($q);
	$q1=query("select * from menu where id=$r[parent]");
	$r1=fetch($q1);
	$data["described"]=strip_tags($data["described"]);
	$r["content"]=str_replace("./var/",$baselink."var/",$r["content"]);
	$r["is_comment"]=$r1["is_comment"];
	$r["is_samecat"]=$r1["is_samecat"];
	$r["time"]=date("H:i d/m/Y",$r["time"]);
	$r["tags"]=explode(",",$r["tags"]);
	$logs=array(
		"time" => time(),
		"idpost" => $id,
		"ip" => $_SERVER['REMOTE_ADDR'],
		"url" => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"
	);
	insert($logs,"logs");
}
$smarty->assign("countbl",count($block));
$smarty->assign("data",$r);
$smarty->display("page.htm");
?>